<?php
/**
 * Created by PhpStorm.
 * User: YONBIN
 * Date: 2020/11/25
 * Time: 12:04
 * Email: 479703456@qq.com
 */

use think\facade\Route;
use app\middleware\common\Auth;
use app\middleware\common\FilterParams;

Route::group(function () {
    Route::any('test$', 'Common/test');
    Route::get('getCaptcha$', 'Common/getCaptcha');
    Route::post('login$', 'Login/login');
});

Route::group(function () {
    Route::get('getPermCode$', 'Common/getPermCode');//新版本后台获取用户权限编码接口
    Route::get('getMenuList$', 'Common/getMenuList');//新版本后台获取用户菜单接口
    Route::get('getUserInfo$', 'Login/getUserInfo');

    Route::get('getDashboard$', 'DashBoard/dashboard');
    Route::get('getNewData$', 'DashBoard/getNewData');

    //+-------------------------------
    //|公用选项相关
    //+-------------------------------
    Route::get('common/admin/menus/[:type]$', 'common/admin_menus');   //获取管理员操作菜单
    Route::get('common/admin/group$', 'common/admin_group'); //获取所有管理员用户组
    Route::get('common/adv/positions$', 'Common/adv_positions'); //获取全部广告位
    Route::post('common/user/search$', 'Common/user_search'); //搜索用户(作为选项)
    Route::get('common/article/category$', 'Common/getArticleCategoryOptions');

    //+---------------------
    //|资源上传相关
    //+---------------------
    Route::any('uploader/chunk$', 'Uploader/uploader_chunk');
    Route::post('uploader/common$', 'Uploader/uploader_common');
    Route::delete('uploader/delete$', 'Uploader/delete');
    Route::post('uploader/rich$', 'Uploader/rich_upload');

    //+----------------------
    //|管理员相关
    //+----------------------
    Route::get('admin/user/:page/:pageSize/[:search]$', 'Admin/retrieve');
    Route::post('admin/user$', 'Admin/create');
    Route::put('admin/user/:id$', 'Admin/update');
    Route::put('changePassword/:id$', 'Admin/changePassword');
    Route::delete('admin/user/:id$', 'Admin/delete');

    //+----------------------
    //|管理员权限组
    //+----------------------
    Route::get('admin/group/:page/:pageSize/[:search]$', 'AdminGroup/retrieve');
    Route::post('admin/group$', 'AdminGroup/create');
    Route::put('admin/group/:id$', 'AdminGroup/update');
    Route::delete('admin/group/:id$', 'AdminGroup/delete');

    //+----------------------
    //|管理员菜单
    //+----------------------
    Route::get('admin/menus$', 'AdminMenus/retrieve');
    Route::post('admin/menus$', 'AdminMenus/create');
    Route::put('admin/menus/:id$', 'AdminMenus/update');
    Route::delete('admin/menus/:id$', 'AdminMenus/delete');

    //+----------------------
    //|设备相关
    //+----------------------
    Route::get('device/:page/:pageSize', 'Device/retrieve');
    Route::post('device$', 'Device/create');
    Route::put('device/:id$', 'Device/update');
    Route::delete('device/:id$', 'Device/delete');

    //+----------------------
    //|设备数据相关
    //+----------------------
    Route::get('getDeviceData/:page/:pageSize/[:search]', 'DeviceData/retrieve');
})->middleware([Auth::class]);

Route::miss(function () {
    return jsonReturn(0, lang('route.miss'), []);
});